{layout name="layout/header" /}
<link href="root/css/plugins/footable/footable.core.css" rel="stylesheet">
<link href="root/css/plugins/iCheck/custom.css" rel="stylesheet">

<link href="root/css/plugins/switchery/switchery.css" rel="stylesheet">
<script src="root/js/plugins/switchery/switchery.js"></script>
<!--<link href="root/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">-->
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>栏目列表</h5>
                </div>
                <div class="ibox-title">
                    <p>
                        <a href="#" class="btn btn-danger btn-outline" id="add">新增</a>
                        <button type="button" class="btn btn-primary btn-outline refresh">刷新</button>
                    </p>
                </div>
                <div class="ibox-content">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>栏目名称</th>
                                <th>类型</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="data.list" id="vo"}
                        <tr pid="{$vo.id}" >
                            <td>{switch name="$vo.level"}
                                {case value="1"}{$vo.name}{/case}
                                {case value="2"}&nbsp;&nbsp;&nbsp;&nbsp;|----{$vo.name}{/case}
                                {/switch}
                            </td>
                            <td>{switch name="$vo.type"}
                                {case value="1"}<span class="text-info">下级栏目</span>{/case}
                                {case value="2"}<span class="text-danger">单页文章</span>{/case}
                                {case value="3"}<span class="text-warning">外部链接</span>{/case}
                                {case value="4"}<span class="text-success">文章列表</span>{/case}
                                {default /}default
                                {/switch}
                            </td>
                            <td>
                                <a type="button" class="btn btn-success btn-sm edit" href="#">编辑</a>
                                {eq name="$vo.type" value="2"}
                                <a type="button" class="btn btn-danger btn-sm edit" href="#">文章</a>
                                {/eq}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!--layer-->
<script src="root/js/plugins/layer/layer.min.js"></script>
<!-- iCheck -->
<script src="root/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function() {

        checks();
        //单选，复选按钮
        function checks () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green'
            })
        }
        var elem = document.querySelectorAll('.js-switch');
        elem.forEach(function(i,index){
            var a= "a" +index;
            a = new Switchery(i, {
            color: '#1AB394'
            });
        });

        //新添扩展字段
        $('#add').click(function () {
            var url = "{:url('add')}";
            edit(url);
        });

        $('.edit').click(function () {
            var id = $(this).parent().parent().attr('pid');
            var url = "{:url('update')}"+"/id/"+id;
            edit(url);
        })
        function edit(url) {
            layer.open({
                type: 2,
                title: "编辑栏目",
                // closeBtn: 0, //不显示关闭按钮
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                // shade: [0],
                area: ['1020px', '700px'],
                content: [url], //iframe的url，no代表不显示滚动条
            });
        }

    });
</script>
